import * as BABYLON from "babylonjs"; //全部引入

function getCurve(originXY, destinationXY) {
  let controlXY = [
    originXY[0] + 0.3 * (destinationXY[0] - originXY[0]),
    originXY[1] + 0.3 * (destinationXY[1] - destinationXY[1])
  ];
  let origin = new BABYLON.Vector3(originXY[0], 0, originXY[1]);
  let destination = new BABYLON.Vector3(destinationXY[0], 0, destinationXY[1]);
  let control = new BABYLON.Vector3(controlXY[0], 4, controlXY[1]);
  let nb_of_points = 20;
  let bezier2 = BABYLON.Curve3.CreateQuadraticBezier(
    origin,
    control,
    destination,
    nb_of_points
  );
  let linepath = bezier2.getPoints();
  return linepath;
  //   BABYLON.MeshBuilder.CreateLines("curlines", {
  //     points: path
  //   });
}
export default getCurve;
